<?php
namespace app\app\controller;
use \app\app\controller\Base;
use \think\Db;
class Index extends Base
{

    public function index()
    {
    	//关于我们
        $us=Db::name('company1')->where("class",'dec')->find();
    	
    	$dec=strip_tags($us['dec']);
    	$this->assign('dec',$dec);
    	// var_dump($e);
		//新闻大事件
        $da_news=Db::name('news')->where("type",'1')->order(["type_sort"=>"asc","id"=>"desc"])->find();
		$this->assign('da_news',$da_news);
		//新闻热点新闻
        $hot_news=Db::name('news')->where("type",'2')->order(["type_sort"=>"asc","id"=>"desc"])->find();
    	$this->assign('hot_news',$hot_news);
    	//成功案例
    	$case=Db::name("lawyer_case")->where("state",'1')->order("id","desc")->limit(4)->select();
    	$this->assign('case',$case);

    	//业务领域
    	$t=Db::name("case_type")->select();
		$type=$this->menulist($t);
    	$this->assign('type',$type);
    	//律师
    	$lawyer=Db::name("lawyer")->order("id","desc")->limit(4)->select();
    	$this->assign('lawyer',$lawyer);
        
        return $this->fetch();
    }
     public function menulist($menu,$id=0,$level=0){
        
        static $menus = array();
        $size = count($menus)-1;
        foreach ($menu as $value) {
            if ($value['pid']==$id) {
                $value['level'] = $level+1;
                if($level == 0)
                {
                    $value['str'] = str_repeat('',$value['level']);
                    $menus[] = $value;
                }
                elseif($level == 2)
                {
                    $value['str'] = '&emsp;&emsp;&emsp;&emsp;'.'└ ';
                    $menus[$size]['list'][] = $value;
                }
                elseif($level == 3)
                {
                    $value['str'] = '&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;'.'└ ';
                    $menus[$size]['list'][] = $value;
                }
                else
                {
                    $value['str'] = '&emsp;&emsp;'.'└ ';
                    $menus[$size]['list'][] = $value;
                }
                
                $this->menulist($menu,$value['id'],$value['level']);
            }
        }
        return $menus;
    }
}
